import time

from pymata4 import pymata4

board = pymata4.Pymata4()

def servo(my_board, pin, start  ):
    """
    Set a pin to servo mode and then adjust
    its position.

    :param end:
    :param start: 脉冲开始 脉冲结束
    :param my_board: pymata4
    :param pin: pin to be controlled
    """

    # set the pin mode
    my_board.set_pin_mode_servo(pin)

    # set the servo to 0 degrees
    my_board.servo_write(pin, start)

if __name__ == '__main__':
    while True:
        servo(board, 6, 60)
        servo(board, 5, 60)
        time.sleep(.5)
        servo(board,6,120)
        servo(board, 5, 120)
        time.sleep(.5)
    # servo(board, 10, 90)

    # while True:
    #
    #     servo(board,11,120)
    #     servo(board, 10, 120)
    #
    #     time.sleep(.5)
    #
    #     servo(board, 11, 50)
    #     servo(board, 10, 50)
    #
    #     time.sleep(.5)


